<template>
	<view class="unquality-install-item">
		<view class="unquality-top">
			<view class="desc">不合格设施</view>
			<view class="right">
				<view class="scan" @click="goScan">
					<image src="/fireGridCheck/static/s.png" mode=""></image>
				</view>
				<text style="color: #3080FB;" @click="goScan">扫一扫添加</text>
			</view>
		</view>
		<view class="info-item" v-for="(item, index) in installList" :key="item.id" >
			<view>
				<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
				<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
				<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
			</view>
			<view class="delete" @click.stop="onDelete(index)">删除</view>
		</view> 
		<!-- <view class="img-content">
			<view>设施编号：F201209162301002</view>
			<view>设施名称：灭火器001</view>
			<view>具体位置：大门口处灭火器</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		props: {
			installType: {
				type: String
			},
			checkId: {
				type: Number
			}
		},
		data() {
			return {
				installList: []
			};
		},
		methods: {
			onDelete(index) {
				this.installList.splice(index,1)
				this.$emit('delete', index)
			},
			goScan() {
				this.$common.scanFacilityCode(this.getInstallDetail, this.installType, this.checkId)
			},
			getInstallDetail(id) {
				this.$http.post('gridSystem/device/info', {
					id
				}).then(res => {
					if (res.code === 10000) {
						console.log(res)
						this.installList.push(res.data)
						this.$emit('add', res.data.id)
					}
				})
			},
		}
	}
</script>

<style lang="scss" >
	.unquality-install-item {
		width: 710rpx;
		// min-height: 258rpx;
		padding: 20rpx;
		border: 2rpx solid #B5B5B5;
		margin-bottom: 20rpx;
		.unquality-top {
			display: flex;
			justify-content: space-between;
		}
		.desc {
			margin-bottom: 20rpx;
		}
		.scan {
			width: 34rpx;
			height: 30rpx;
			margin-right: 12rpx;
			margin-top: 2rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.right {
			display: flex;
			//vertical-align: middle;
			// align-items: center;
		}
		.img-content {
			// display: flex;
			.img-item {
				width: 100rpx;
				height: 100rpx;
				margin: 10rpx;
				// image {
				// 	width: 100%;
				// 	height: 100%;
				// }
			}
		}
		.info-item {
			position: relative;
			box-shadow: 0px 1px 6rpx 0px #EEEEEE;
			border-radius: 8rpx;
			margin-bottom: 10rpx;
			font-size: 32rpx;
			.info-title {
				margin-bottom: 20rpx;
			}
			.info-wrap {
				line-height: 50rpx;
				font-size: 28rpx;
				width: 20em;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
			.delete {
				position: absolute;
				right: 20rpx;
				bottom: 10rpx;
				text-align: center;
				line-height: 35rpx;
				width: 70rpx;
				height: 35rpx;
				font-size: 22rpx;
				color: #E57544;
				border: 2rpx solid #E57544;
			}
		}
	}
</style>
